<template>
    <el-menu
        class="categories"
        :default-active="activeMenu"
        @select="handleSelect"
        active-text-color="red" >
        <el-menu-item v-for="item in menus" :key="item.id" :index="item.id.toString()" >
            <i :class="item.icon"></i>
            <span slot="title">{{ item.name }}</span>
        </el-menu-item>
    </el-menu>
</template>

<script>
    export default {
        props: [ 'menus' ],
        data () {
            return {
                activeMenu: '0'
            }
        },
        methods: {
            handleSelect (key, keyPath) {
                this.activeMenu = key.toString();
                // 调用父页面接口重新获取该标签下的数据
                this.$emit('indexSelect', key);
            }
        }
    }
</script>

<style scoped>
    .categories {
        position: fixed;
        margin-left: 10%;
        top: 130px;
        width: 150px;
    }
</style>

